package cn.stylefeng.guns.modular.util;

/**
 *
 * Id生成器
 *
 * @author by jzy on 2019/12/24.
 */
public class Snowflake{

	public Snowflake(int num){
		numx10000 = num * 10000;
	}

	private int numx10000;
	private int idCount = 0;

	long getNextId(){
		if (++idCount > 9999){
			//编号超过9999了 等待到下一毫秒
			try {
				Thread.sleep(1);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			idCount = 0;
		}
		return System.currentTimeMillis()*1000000+numx10000+idCount;
	}
}